{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}

module Generics.MultiRec.Languages.JavaScript.JavaScript where

import Generics.MultiRec
import Generics.MultiRec.TH.Alt

import HJS.Parser.JavaScript

data JS :: (* -> *) where
  TheLiteral :: JS Literal
  ThePrimExpr :: JS PrimExpr
  TheGetterPutter :: JS GetterPutter
  ThePropName :: JS PropName
  TheArrayLit :: JS ArrayLit
  TheMemberExpr :: JS MemberExpr
  TheCallExpr :: JS CallExpr
  TheNewExpr :: JS NewExpr
  TheLeftExpr :: JS LeftExpr
  ThePostFix :: JS PostFix 
  TheUExpr :: JS UExpr
  TheAExpr :: JS AExpr
  TheCondE :: JS CondE
  TheAssignOp :: JS AssignOp
  TheAssignE :: JS AssignE
  TheAssignEList :: JS [AssignE]
  TheAssignEMaybe :: JS (Maybe AssignE)
  TheExpr :: JS Expr
  TheExprMaybe :: JS (Maybe Expr)
  TheVarDecl :: JS VarDecl
  TheVarDeclList :: JS [VarDecl]
  TheIfStmt :: JS IfStmt
  TheItStmt :: JS ItStmt
  TheTryStmt :: JS TryStmt
  TheCatch :: JS Catch
  TheCatchList :: JS [Catch]
  TheStmt :: JS Stmt
  TheStmtList :: JS [Stmt]
  TheStmt' :: JS Stmt'
  TheSwitch :: JS Switch
  TheCaseBlock :: JS CaseBlock
  TheCaseClause :: JS CaseClause
  TheCaseClauseList :: JS [CaseClause]
  TheFuncDecl :: JS FuncDecl
  TheSourceElement :: JS SourceElement
  TheSourceElementList :: JS [SourceElement]
  TheJSProgram :: JS JSProgram
  TheString :: JS String
  TheStringMaybe :: JS (Maybe String)
  TheBool :: JS Bool
  TheStringPair :: JS (String,String)
  TheIntPair :: JS (Int,Int)
  TheObject :: JS ( (Either ((,) PropName AssignE) GetterPutter) )
  TheObjectList :: JS ( [] (Either ((,) PropName AssignE) GetterPutter) )

$(deriveEverything
  (DerivOptions
   [ ( [t| Literal |]    , "TheLiteral" )
   , ( [t| PrimExpr |] ,"ThePrimExpr")
   , ( [t| PropName|] ,"ThePropName")
   , ( [t| ArrayLit|] ,"TheArrayLit")
   , ( [t| MemberExpr |] ,"TheMemberExpr")
   , ( [t| CallExpr|] ,"TheCallExpr")
   , ( [t| NewExpr |] ,"TheNewExpr")
   , ( [t| LeftExpr |] ,"TheLeftExpr")
   , ( [t| PostFix |] ,"ThePostFix")
   , ( [t| UExpr |] ,"TheUExpr")
   , ( [t| AExpr |] ,"TheAExpr")
   , ( [t| CondE |] ,"TheCondE")
   , ( [t| AssignOp |] ,"TheAssignOp")
   , ( [t| AssignE |] ,"TheAssignE")
   , ( [t| [AssignE] |] ,"TheAssignEList")
   , ( [t| Maybe AssignE |] ,"TheAssignEMaybe")
   , ( [t| Expr |] ,"TheExpr")
   , ( [t| Maybe Expr |] ,"TheExprMaybe")
   , ( [t| VarDecl |] ,"TheVarDecl")
   , ( [t| [VarDecl] |] ,"TheVarDeclList")
   , ( [t| IfStmt |] ,"TheIfStmt")
   , ( [t| ItStmt |] ,"TheItStmt")
   , ( [t| TryStmt |] ,"TheTryStmt")
   , ( [t| Catch |] ,"TheCatch")
   , ( [t| [Catch] |] ,"TheCatchList")
   , ( [t| Stmt |] ,"TheStmt")
   , ( [t| [Stmt] |] ,"TheStmtList")
   , ( [t| Stmt'|] ,"TheStmt'")
   , ( [t| Switch |] ,"TheSwitch")
   , ( [t| CaseBlock |] ,"TheCaseBlock")
   , ( [t| CaseClause |] ,"TheCaseClause")
   , ( [t| [CaseClause] |] ,"TheCaseClauseList")
   , ( [t| FuncDecl |] ,"TheFuncDecl")
   , ( [t| SourceElement |] ,"TheSourceElement")
   , ( [t| [SourceElement] |] ,"TheSourceElementList")
   , ( [t| JSProgram |] ,"TheJSProgram")
   , ( [t| Maybe String |] ,"TheStringMaybe")
   , ( [t| (String,String) |] ,"TheStringPair")
   , ( [t| (Int,Int) |] ,"TheIntPair")
   , ( [t| Bool |] ,"TheBool")
   , ( [t| (Either ((,) PropName AssignE) GetterPutter) |] ,"TheObject")
   , ( [t| [] (Either ((,) PropName AssignE) GetterPutter) |] ,"TheObjectList")
   ]
   "JS"
   (\t c -> "CONSTRUCTOR_" ++ t ++ "_" ++ c)
   "ThePF"
   True
  )
 )

type instance PF JS = ThePF
